#include "widget.h"
#include "ui_widget.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QSpacerItem>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QHBoxLayout *layout = new QHBoxLayout(this);
    QPushButton *p1 = new QPushButton("按钮1");
    QPushButton *p2 = new QPushButton("按钮2");
    QSpacerItem *sp1 = new QSpacerItem(200, 10);

    // spacer展现出来的位置就代表着layout添加的位置
    layout->addWidget(p1);
    layout->addItem(sp1);
    layout->addWidget(p2);
}

Widget::~Widget()
{
    delete ui;
}

